package cn.thoughtworks.school.repositories;

import cn.thoughtworks.school.entities.Tag;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;

public interface TagRepository extends JpaRepository<Tag,Long>{
  Stream<Tag> findTagByName(String name);

  Page<Tag> findAllByOrganizationId(Long organizationId, Pageable pageable);

  Optional<Tag> findFirstByNameAndOrganizationId(String name, Long organizationId);

  List<Tag> getTagsByOrganizationIdAndNameContaining(Long organizationId, String name, Pageable topTen);

  List<Tag> findAllByOrganizationId(Long organizationId);

  List<Tag> findAllByOrganizationIdAndNameIn(Long organizationId, List<String> tagsName);

}
